package com.ash.html2image;

import gui.ava.html.image.generator.HtmlImageGenerator;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @Author Ashin
 * @Date 2019/7/8
 */

public class Html2ImageTest {

    public static void main(String[] args) throws MalformedURLException {
        StringBuilder html = new StringBuilder();
        html.append("<table style=\"border:1px solid red;border-collapse:collapse; width: 500px;\">\n" +
                "    <tr class=\"title\" style=\"border-bottom:1px dashed black;text-align: center;\">\n" +
                "        <td colspan=\"2\">福建省测试医院诊间结算单据</td>\n" +
                "\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td>姓名：测试名</td>\n" +
                "        <td>科室：测试科室</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">IC卡号：A90**90</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">打印时间：2019-06-10 10:00:10</td>\n" +
                "    </tr>\n" +
                "\n" +
                "    <tr>\n" +
                "        <td>结算成功</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">您本次门诊结算总金额为 500.00</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\"> 具体金额明细如下：</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">\n" +
                "            <b>本次费用总额： 500.00</b>\n" +
                "        </td>\n" +
                "\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">\n" +
                "            个人账户支付： 300.00\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">\n" +
                "            基金支付金额： 200.00\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">\n" +
                "            个人支付金额： 0.00\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "    <tr style=\"border-bottom:1px dashed black;\">\n" +
                "        <td colspan=\"2\">\n" +
                "            个人账户余额： 100.00\n" +
                "        </td>\n" +
                "    </tr>\n" +
                "\n" +
                "    <tr>\n" +
                "    <th>门诊费用明细</th>\n" +
                "    <th>金额（元）</th>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td>诊查费</td>\n" +
                "        <td>90</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\">您可凭借以下二维码到取药窗口扫码取药</td>\n" +
                "    </tr>\n" +
                "    <tr>\n" +
                "        <td colspan=\"2\" style=\"text-align: center;\"><img style=\"width: 400px;height: 500px;border: 1px solid blue\" src=\"http://img3.redocn.com/20120712/Redocn_2012071219434059.jpg\"></td>\n" +
                "    </tr>\n" +
                "\n" +
                "    <tr><td colspan=\"2\">如您有疑问，请前往导诊台咨询</td></tr>\n" +
                "    \n" +
                "</table>");


        HtmlImageGenerator imageGenerator = new HtmlImageGenerator();
        imageGenerator.loadHtml(html.toString());
        imageGenerator.saveAsImage("hello-world.png");
    }
}

